package cn.koala.key.receipt.controller;

import cn.koala.key.entity.KeyInfo;
import cn.koala.key.receipt.dto.BorrowOrderDetailDTO;
import cn.koala.key.receipt.service.BorrowOrderDetailService;
import cn.ehi.authority.annotation.WebAuthentication;
import cn.seed.common.core.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @description:借用单钥匙信息
 * @author 32415
 * @time 2019/04/28
 **/
@RestController
@RequestMapping("/borrow-order-details")
@Api(value = "BorrowOrderDetail",tags = "借用单明细信息")
public class BorrowOrderDetailController {

    @Autowired
    private BorrowOrderDetailService borrowOrderDetailService;

    @ApiOperation(value = "获取借用单借用的钥匙信息")
    @GetMapping("/{orderNo}")
    public Result<List<KeyInfo>> getByOrderNo(@PathVariable String orderNo) {
        return borrowOrderDetailService.getByOrderNo(orderNo);
    }

    @ApiOperation(value = "新增借出信息, 属于中心确认操作")
    @PostMapping("/out")
    @WebAuthentication(systemCode = "KoalaKey",moduleIds = "KOALAKEY_B_00006")
    public Result lend(@RequestBody BorrowOrderDetailDTO borrowOrderDetailDTO) {
        return borrowOrderDetailService.lend(borrowOrderDetailDTO);
    }
}
